package com.wsc.wsckeeper.components;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

public class CardNumberTextView extends TextView {
	private static final int GROUP_NUMBER = 4;

	public CardNumberTextView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public CardNumberTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public CardNumberTextView(Context context) {
		super(context);
	}

	@Override
	public void setText(CharSequence text, BufferType type) {
		StringBuilder value = new StringBuilder(text);
		for (int i = GROUP_NUMBER; i < value.length(); i = i + GROUP_NUMBER) {
			value.insert(i, " ");
			i++;
		}
		super.setText(value, type);
	}

}
